# -*- coding: utf-8 -*- 
import time
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

brower = webdriver.Chrome(executable_path = r"D:/user/Downloads/chromedriver")
brower.get("http://itsm-rpt.sf-express.com/balantflow/")

#z1 = "http://itsm-rpt.sf-express.com/balantflow/task/getTaskDetail.do?taskId=%s" %(z2) 
#z2 = sys.argv
#账号
zh = brower.find_element_by_id("username")
zh.send_keys("01383317")

#密码RL003694795
mm = brower.find_element_by_id("password")
mm.send_keys("liuj1a!wei")
print u"""
          请输入验证码
          有8秒时间
		  请不要点击登录按钮
		  """
time.sleep(8)
print u"自动点击登陆"
brower.find_element_by_css_selector(".f18.logn_lt.logn_btn.lh46").click()
print u"打开新标签OK"
js = " window.open('http://itsm-rpt.sf-express.com/balantflow/task/getTaskDetail.do?taskId=3694795')"
print u"打开新网页OK"
time.sleep(2)
brower.execute_script(js)
print u"切换到新标签OK"
tabs = brower.window_handles
brower.switch_to_window(tabs[1])
time.sleep(2)
a = brower.find_elements_by_class_name("divTitle")
b = brower.find_elements_by_class_name("divControl")

print u"=========以下为检查结果============"

print u"=====重要信息===="		
for i in range(len(a)):
    if a[i].text == u'\u7cfb\u7edf\u7ef4\u62a4\u65f6\u95f4\u7a97\u53e3\uff1a':
        print a[i].text, b[i].text
    if a[i].text == u'\u6b63\u5f0f\u53d1\u5e03\uff1a':
	    print a[i].text, b[i].text
		
		
print u"=====完整信息===="		
for i2 in range(len(a)):
	print a[i2].text, b[i2].text


time.sleep(3)
print u"开始附件下载"

print u"点击附件ww"
fuj = brower.find_element_by_xpath('//*[@id="divStepContent2078"]/table/tbody/tr/td[2]/ul/li[2]/a')
fuj.click()
time.sleep(1)

print u"点击下载新特性列表"
wjm = brower.find_element_by_id("divFileGroup11").text
wjm1 = wjm.split()
wjm2 = wjm1[0]
print wjm2
brower.find_element_by_link_text(wjm2).click()





#asj = b[28].text#A时间是正式发布时间,B时间是维护窗口
#asj1 = asj.split()#[u'\u5f00\u59cb\u65f6\u95f4\uff1a', u'2019-01-09', u'12:00', u'-', u'\u7ed3\u675f\u65f6\u95f4\uff1a', u'2019-01-09', u'15:00']
#bsj = b[6].text
#bsj1 = bsj.split("-")#[u'12:00', u'15:00']
#time.sleep(2)














#if asj1[1] == asj1[5] and asj1[2] <= bsj1[0] and asj1[6] <= bsj1[1]:
#    print u"系统在维护窗口"
#else:
#    print u"系统不再维护窗口,再看一次咯"
#print  a[0].text, b[0].text
#for i in range(len(a)):
#    print a[i].text
#for i1 in range(len(b)):
#    print b[i1].text
